<?php
/**
 * Joomla! 1.5 component JoomGPSTracks
 *
 * @version $Id: form.php 2009-06-24 15:40:19 svn $
 * @author Michael Pfister
 * @package joomGPStracks
 * @subpackage frontend
 * @license GNU/GPL
 * @filesource
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

if(isset($this->id)) {
    $description = $this->track->description;
    $button = "submitbutton('update')";
    $title = JText::_('GPS_UPDATE');
} else {
    $description = "";
    $button = "submitbutton('save')";
    $title = JText::_('GPS_NEW_TRACK');
}

?>
<script language="javascript" type="text/javascript">

function submitbutton(pressbutton)
{
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
    // do field validation
	if (document.getElementById('title').value == ""){
		alert( "<?php echo JText::_( 'GPS_NEED_TITLE', true ); ?>" );
    }  
    <?php if($this->cfg->terms == 1)  { ?>
        else if (document.getElementById('terms').checked == false) {
            alert( "<?php echo JText::_( 'GPS_NEED_TERMS', true ); ?>" );
        } else {
		submitform( pressbutton );
        }
        <?php } else { ?>
         else {
            submitform( pressbutton);
        }
        <?php } ?>

}
</script>
<?php echo $this->lh; ?>
<div class="componentheading"><?php echo $title; ?></div>
<div>
<form name="adminForm" id="adminForm" method="post" enctype="multipart/form-data" action="<?php echo JRoute::_($this->action); ?>">
    <table width="100%">
        <tbody>
            <tr>
                <td><?php echo JText::_('GPS_TITLE'); ?>*</td>
                <td><input id="title" type="text" name="title" value="<?php if(isset($this->id)) echo $this->track->title; ?>" size="30" /></td>
            </tr>
            <tr>
                <td><?php echo JText::_('GPS_LEVEL'); ?>* <?php echo JHTML::tooltip(JText::_('GPS_TT_LEVEL'), JText::_('GPS_TT_HEADER'),'tooltip.png'); ?></td>
                <td><select name="level">
                        <option><?php echo JText::_('GPS_SELECT'); ?></option>
                        <option value="1" <?php if(isset($this->id) && $this->track->level == 1): echo "selected='selected'"; endif; ?> >1</option>
                        <option value="2" <?php if(isset($this->id) && $this->track->level == 2): echo "selected='selected'"; endif; ?> >2</option>
                        <option value="3" <?php if(isset($this->id) && $this->track->level == 3): echo "selected='selected'"; endif; ?> >3</option>
                        <option value="4" <?php if(isset($this->id) && $this->track->level == 4): echo "selected='selected'"; endif; ?> >4</option>
                        <option value="5" <?php if(isset($this->id) && $this->track->level == 5): echo "selected='selected'"; endif; ?> >5</option>
                    </select></td>
            </tr>
            <tr>
                <td><?php echo JText::_('GPS_CAT'); ?></td>
                <td><?php echo $this->lists['content']; ?></td>
            </tr>
            <?php
            if($this->cfg->access == 1)  {
            ?>
            <tr>
                <td><?php echo JText::_('GPS_ACCESS_LEVEL'); ?>&nbsp;<?php echo JHTML::tooltip(JText::_('GPS_TT_ACCESS'), JText::_('GPS_TT_HEADER'),'tooltip.png'); ?></td>
                <td><?php echo $this->lists['access']; ?></td>
            </tr>
            <?php } ?>
            <?php
            if(!isset($this->id))  {
            ?>
            <tr>
                <td><?php echo JText::_('GPS_FILE'); ?>* <?php echo JHTML::tooltip(JText::_('GPS_TT_FILES'), JText::_('GPS_TT_HEADER'),'tooltip.png'); ?></td>
                <td><input type="file" name="file" value="" size="30" /></td>
            </tr>
            <?php } ?>
            <tr>
                <td><?php echo JText::_('GPS_TERRAIN'); ?> <?php echo JHTML::tooltip(JText::_('GPS_TT_TERRAIN'), JText::_('GPS_TT_HEADER'),'tooltip.png'); ?></td>
                <td><?php echo $this->lists['terrain']; ?></td>
            </tr>
            <tr>
                <td><?php echo JText::_('GPS_DESCRIPTION'); ?>* <?php echo JHTML::tooltip(JText::_('GPS_TT_DESC'), JText::_('GPS_TT_HEADER'),'tooltip.png'); ?></td>
                <td><?php echo $this->editor->display( 'description', $description , '500', '200', '15', '25', false ) ; ?></td>
            </tr>
            <tr>
                <td valign="top"><?php echo JText::_('GPS_IMAGES'); ?> (max. 10)</td>
                <td><input type="file" name="images[]" class="multi" maxlength="10"><br clear="all"/></td>
            </tr>
            <?php
            if($this->cfg->terms == 1):
            ?>
            <tr>
                <td><?php echo JText::_('GPS_TERMS'); ?></td>
                <td><input id="terms" type="checkbox" name="terms" value="" /><?php echo JText::_('GPS_AGREE'); ?> <a class="modal" href="<?php echo $this->terms; ?>" target="_blank"><?php echo JText::_('GPS_TERMS'); ?></a></td>
            </tr>
            <?php
            endif;
            ?>
        </tbody>
    </table>
    <?php
    echo JHTML::_( 'form.token' ) . "\n"; ?>
    <input type="hidden" name="option" value="com_joomgpstracks" />
    <input type="hidden" name="controller" value="tracks" />
    <?php
    if(isset($this->id)) echo '<input type="hidden" name="id" value="'.$this->id.'" />';
    ?>
    <input type="hidden" name="task" value="" />
<div>
	<button class="button" type="button" onclick="<?php echo $button; ?>">
		<?php echo JText::_('Save') ?>
	</button>
	<button class="button" type="button" onclick="submitbutton('cancel')">
		<?php echo JText::_('Cancel') ?>
	</button>
</div>
</form>
</div>
<?php
echo $this->footer;
?>
